﻿using Dapr.Actors;
using Dapr.Actors.Client;
using FEShop.AppUserService.Services.Dtos.Account;
using FEShop.AppUserService.Services.Implementations;
using FEShop.AppUserService.Services.Interfaces;
using FEShop.OpenModel.Common;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;

namespace FEShop.AppUserService.Controllers
{

    /// <summary>
    /// 用户账户相关：注册、登录、登出
    /// </summary>
    [ApiController]
    [Route("api/[controller]")]
    public class AccountController : ControllerBase
    {
        private readonly ILogger<AccountController> _logger;
        private readonly IAccountService _accountService;
        /// <summary>
        /// 
        /// </summary>
        public AccountController(ILogger<AccountController> logger, IAccountService accountService)
        {
            _logger = logger;
            _accountService = accountService;
        }

        /// <summary>
        /// 用户登陆
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        [HttpPost("login")]
        public async Task<ResultObject<LoginOutputDto>> UserLoginAsync([FromBody] LoginInputDto dto)
        {
            Console.WriteLine("============用户登陆=============参数：");
            Console.WriteLine(JsonConvert.SerializeObject(dto));
            var result =  await _accountService.LoginAsync(dto);
            return result;
        }

      

    }
}
